package com.maisuiit.Thread;

/**
 * 功能：通过Runnable接口创建线程
 */
public class Thread02 {
    public static void main(String[] args) {
        //启动
        Dog1 dog=new Dog1();
        //创建一个Thread线程对象
        Thread t=new Thread(dog);
        t.start();
    }
}

class Dog1 implements Runnable{
    public void run() {
        int times=0;
        while(true){
            try {
                Thread.sleep(1000);
            } catch (Exception e) {
                e.printStackTrace();
            }
            times++;
            System.out.println("hello,wrold!"+times);
            if(times==10){
                break;
            }
        }
    }
}